package com.jiang.daily.Q2874;

/**
 * @author Jiang
 * @version 1.0
 * @date 2025/04/02 11:10
 */
public class Solution {
    public long maximumTripletValue(int[] nums) {
        long res = 0, v1 = 0, v2 = 0;
        for (int k = 0; k < nums.length; k++) {
            res = Math.max(res, v2 * nums[k]);
            v2 = Math.max(v2, v1 - nums[k]);
            v1 = Math.max(v1, nums[k]);
        }
        return res;
    }
}
